<?php
/**
 * JoiGallery - image gallery component for Joostina
 *
 * Менеджер категорий
 *
 * @version 1.0 alpha 12
 * @package JoiGallery
 * @subpackage	AdminView
 * @filename category_list.php
 * @author JoostinaTeam
 * @copyright (C) 2008-2009 Joostina Team
 * @license see license.txt
 *
 **/
 
defined('_VALID_MOS') or die();

//Загружаем FancyBox
if ($params->get('adm_cat_list_thumbs_fb')) {
    mosCommonHTML::loadJqueryPlugins('fancybox/jquery.fancybox',false, true);
}

?>

<table class="adminheading">
  <tr>
    <th class="categories">
     <?php echo _C_JOIGALLERY_COMPONENT;
           echo _C_JOIGALLERY_CATEGORIES;
      ?>
    </th>
    <!--<td nowrap="nowrap">--><?php //echo _C_JOIGALLERY_CATEGORY ?> <?php //echo $lists['cid']; ?><!--</td>-->
  </tr>
</table>

<form action="index2.php" method="post" name="adminForm">

  <table class="adminlist" border="0">
    <tr>
      <th width="10" class="acenter">#</th>
      <th width="20"><input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count( $rows );?>);" /></th>
	  <th class="title"><?php echo _C_JOIGALLERY_CATEGORY_NAME ?></th>
      <th width="10%"><?php echo _C_JOIGALLERY_PUBLISHED ?></th>
      <th width="2%" style="padding:0 5px 0 5px"  colspan="2">
         <?php echo _C_JOIGALLERY_CATEGORY_ORDER ?>
      </th>
      <th width="2%" class="acenter" style="border-left:inherit;">
           <a href="javascript: saveorder( <?php echo count( $rows )-1; ?> )">
             <img src="images/filesave.png" border="0" style="margin-left:5px;" width="16" height="16" alt="Сохранить" />
           </a>
      </th>      
	  <th width="10%" class="title acenter"><?php echo _C_JOIGALLERY_PHOTOS_IN_CAT ?></th>
	  <?php if ($params->get('adm_cat_list_thumbs')) { ?>
	    <th class="title acenter" width="75"><?php echo _C_JOIGALLERY_PHOTO_GALLERY_THUMBNAIL ?></th>
	  <?php } ?>
      <th width="20" style="text-align: center" nowrap>ID<?php //echo _C_JOIGALLERY_CATEGORY_ID ?></th>
    </tr>
    <?php
    $k = 0;
    for ($i=0, $n=count( $rows ); $i < $n; $i++) {
    $row  = &$rows[$i];

    $link = 'index2.php?option='.$option.'&amp;act=categories&amp;task=edit&amp;hidemainmenu=1&amp;cid='.$row->id;
    $row->name = $row->treename;
	$parent_id = $cat->get_cat_field_by_cid($row->id, 'parent_id');		 
	$category_name = ($parent_id) 
	               ?  '<span class="red">'.$cat->get_cat_field_by_cid($parent_id, 'name').'</span>' 
	               : _C_JOIGALLERY_CATEGORY_ROOT;

    $icon_path = JPATH_SITE.'/'.JADMIN_BASE.'/templates/'.JTEMPLATE.'/images/ico';
    $icon = $row->published ? 'publish_g.png' : 'publish_x.png';
	$rel = ($params->get('adm_cat_list_thumbs_fb_group')=='all') ? 'rel="all"' : '';
    ?>

    <tr class="row<?php echo $k; ?>" id="tr-el-<?php echo $row->id;?>">
      <td align="right"><?php echo $pageNav->rowNumber( $i ); ?></td>
      <td><?php echo mosHTML::idBox($i, $row->id); ?></td>
	  <td><a href="<?php echo $link; ?>"><?php echo stripslashes( $row->name ) .' ( '. stripslashes( $row->title ) .' )'; ?> </a></td>      
      <td align="center" <?php echo ($row->checked_out && ($row->checked_out != $my->id)) ? null : 'onclick="ch_publ('.$row->id.',\'com_categories\');" class="td-state"';?>>
	    <img class="img-mini-state" src="<?php echo $icon_path;?>/<?php echo $icon;?>" id="img-pub-<?php echo $row->id;?>" alt="<?php echo _PUBLISHING?>" />
      </td>
      <td><?php echo $pageNav->orderUpIcon( $i ); ?></td>
      <td><?php echo $pageNav->orderDownIcon( $i, $n ); ?></td>
      <td align="center">
        <input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?>" class="text_area" style="text-align: center" />
      </td>            
      <td align="center">
        <?php echo $photos->get_count_photos($row->id); ?>
      </td>
      <?php if ($params->get('adm_cat_list_thumbs')) { ?>
        <td align="center">          	  
			<?php if ($params->get('adm_cat_list_thumbs_fb')) { ?>
			  <a class="thumb" target="_blank" <?php echo $rel;?> href="<?php echo JPATH_SITE.$params->original_path.'/'.$cat->get_cat_default_thumb_field($row->id); ?>" title="<?php echo _C_JOIGALLERY_PHOTO_GALLERY_THUMBNAIL ?>&nbsp;::&nbsp;<?php echo $row->title; ?>">
                <?php    echo joiGalleryHelper::imgThumb ($thumb_source, $cat->get_cat_default_thumb_field($row->id), $params, 'cat_list'); ?>
			  </a>
			<?php } else echo joiGalleryHelper::imgThumb ($thumb_source, $cat->get_cat_default_thumb_field($row->id), $params, 'cat_list'); ?>          
        </td>
      <?php }//if ?>  
      <td align="center"><?php echo $row->id; ?></td>
      
      <?php
      $k = 1 - $k;
      ?>
    </tr>
    <?php
    }
    ?>
  </table>

  <?php echo '<div class="adminlistfooter">'.$pageNav->getListFooter().'</div>'; ?>

  <input type="hidden" name="option" value="<?php echo $option; ?>" />
  <input type="hidden" name="task" value="" />
  <input type="hidden" name="act" value="categories" />
  <input type="hidden" name="boxchecked" value="0" />
  <input type="hidden" name="hidemainmenu" value="0" />
  
</form>

<script type="text/javascript">
  $(document).ready(function() {
   $("input").attr('autocomplete', 'off'); //Убираем "autocomplete" 
  });
  $("a.thumb").fancybox();
</script>